﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DZ.Data_Modals;  //CP@07.Dec14
using DZ.Data__Class;
namespace DZ.Forms
{
    /// <summary>
    /// Interaction logic for Protocol.xaml
    /// </summary>
    public partial class Protocol : Window
    {
        DB_DZA_Entities dbContext = new DB_DZA_Entities();
        TblAntibody objAntibody = new TblAntibody();
        public Protocol()
        {
            InitializeComponent();

            FillCombovalue();
        }
        private void FillCombovalue()
        {
            try
            {
                //Incubation Time
                DataItem diIncubation = new DataItem();


                //diIncubation = new DataItem();
                //diIncubation.Key = 0;
                //diIncubation.Name = "Select";
                //cmbIncubation.Items.Add(diIncubation);

                diIncubation = new DataItem();
                diIncubation.Key = 0;
                diIncubation.Name = "All";
                cmbIncubation.Items.Add(diIncubation);

                diIncubation = new DataItem();
                diIncubation.Key = 2;
                diIncubation.Name = "30";
                cmbIncubation.Items.Add(diIncubation);

                diIncubation = new DataItem();
                diIncubation.Key = 3;
                diIncubation.Name = "60";
                cmbIncubation.Items.Add(diIncubation);
                cmbIncubation.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void FillGrid()
        {
            try
            {
               
                
                //int intCubateT = Convert.ToInt32(cmbIncubation.Text);
               //int  intCubateT = 30;
                List<TblAntibody> TableData = dbContext.TblAntibodies.Where(s => s.IncubationTime == cmbIncubation.SelectedIndex ).ToList();
                gvAntiBody.ItemsSource = TableData;
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
        }

        private void cmbIncubation_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                FillGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

       

        private void gvAntiBody_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                objAntibody = gvAntiBody.SelectedItem as TblAntibody;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
               
               // AntID = objAntibody.AnBID_PK;
               // MessageBox.Show(AntID.ToString());
                var frmNewAntiBody = new Forms.NewAntiBodyRegistration(objAntibody.AnBID_PK);
                //frmNewAntiBody.AntID = objAntibody.AnBID_PK ;
                frmNewAntiBody.ShowDialog();


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        void newWindow_RaiseCustomEvent(object sender, CustomEventArgs e)
        {
            this.Title = e.Message;
        }

        private void bntClose_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
       
    }
}
